package com.veryedu.hibernate.biz.bean;

import java.sql.Timestamp;
import java.text.ParseException;

import com.veryedu.hibernate.commons.Constant;

public class TimeBean implements Comparable<TimeBean>{
	private Integer showTimeId;
	private String time;
	private String roomname;
	private String price;
	
	public Integer getShowTimeId() {
		return showTimeId;
	}
	public void setShowTimeId(Integer showTimeId) {
		this.showTimeId = showTimeId;
	}
	public String getTime() {
		return time;
	}
	public void setTime(String time) {
		this.time = time;
	}
	public String getRoomname() {
		return roomname;
	}
	public void setRoomname(String roomname) {
		this.roomname = roomname;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	
	@Override
	public int compareTo(TimeBean o) {
		int result = 0;
		try{
			Timestamp thisTime = new Timestamp(Constant.HH_MM.parse(this.time).getTime());
			Timestamp otherTime = new Timestamp(Constant.HH_MM.parse(o.getTime()).getTime());
			
			if(thisTime.before(otherTime)) result = -1;
			else if(thisTime.after(otherTime)) result = 1;
			else result = 0;
			
		}catch(ParseException e){
			e.printStackTrace();
		}
		return result;
	}
}
